<?php

/**
 * This is the model class for table "shop".
 *
 * The followings are the available columns in table 'shop':
 * @property integer $id
 * @property integer $owner
 * @property string $name
 * @property string $description
 * @property integer $shop_category
 * @property string $address
 * @property integer $cityid
 * @property string $mobile
 * @property string $meta_key
 * @property string $meta_des
 * @property string $type
 * @property string $domain_name
 * @property integer $templateid
 * @property string $active_code
 * @property string $created_date
 * @property string $status
 * @property string $is_approved
 */
class Shop extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @param string $className active record class name.
	 * @return Shop the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'shop';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('owner, shop_category, cityid, templateid', 'numerical', 'integerOnly'=>true),
			array('name, description, address, meta_key, meta_des', 'length', 'max'=>255),
			array('mobile, domain_name, active_code', 'length', 'max'=>50),
			array('type, status', 'length', 'max'=>1),
			array('is_approved', 'length', 'max'=>4),
			array('created_date', 'safe'),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('id, owner, name, description, shop_category, address, cityid, mobile, meta_key, meta_des, type, domain_name, templateid, active_code, created_date, status, is_approved', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'id' => 'ID',
			'owner' => 'Owner',
			'name' => 'Name',
			'description' => 'Description',
			'shop_category' => 'Shop Category',
			'address' => 'Address',
			'cityid' => 'Cityid',
			'mobile' => 'Mobile',
			'meta_key' => 'Meta Key',
			'meta_des' => 'Meta Des',
			'type' => 'Type',
			'domain_name' => 'Domain Name',
			'templateid' => 'Templateid',
			'active_code' => 'Active Code',
			'created_date' => 'Created Date',
			'status' => 'Status',
			'is_approved' => 'Is Approved',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('id',$this->id);
		$criteria->compare('owner',$this->owner);
		$criteria->compare('name',$this->name,true);
		$criteria->compare('description',$this->description,true);
		$criteria->compare('shop_category',$this->shop_category);
		$criteria->compare('address',$this->address,true);
		$criteria->compare('cityid',$this->cityid);
		$criteria->compare('mobile',$this->mobile,true);
		$criteria->compare('meta_key',$this->meta_key,true);
		$criteria->compare('meta_des',$this->meta_des,true);
		$criteria->compare('type',$this->type,true);
		$criteria->compare('domain_name',$this->domain_name,true);
		$criteria->compare('templateid',$this->templateid);
		$criteria->compare('active_code',$this->active_code,true);
		$criteria->compare('created_date',$this->created_date,true);
		$criteria->compare('status',$this->status,true);
		$criteria->compare('is_approved',$this->is_approved,true);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}
}